package com.zzty.training.controller;


import com.zzty.training.entity.Clazz;
import com.zzty.training.entity.User;
import com.zzty.training.service.ClazzService;
import com.zzty.training.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/register")
public class RegisterController {
    @Autowired
    UserService userService;
    @Autowired
    ClazzService clazzService;

    @RequestMapping("/addUser")
    public Integer addUser(User user){
        Integer result=userService.addUser(user);
        return result;
    }

    @RequestMapping(value = "/getUser",method = RequestMethod.POST)
    public User checkUser(User user){
        User user1=userService.getUserByNameOrEmail(user);
        return user1;
    }
    @RequestMapping("/getAllClazz")
    public List<Clazz> getAllClazz(){
        List<Clazz> clazzList=clazzService.getAllClazz();
        System.out.println(clazzList);
        return clazzList;
    }
}
